<?php
class AdminController extends AtomController {
	public $defaultAction = 'index';
	
	public function filters() {
		return array(
			array('application.filters.RbacExFilter - roles'),
		);
	}

	public function getActionNames() {
		return array(
			'index' => 'Adminpanel',
			'users' => 'Manage Users',
			'roles' => 'Manage Roles',
		);
	}

	public function actionIndex(){
		$this->render('index');
	}

	public function actionUsers() {
		$criteria = new CDbCriteria;

		$usersCount=User::model()->count($criteria);
		$pages=new CPagination($usersCount);
		$pages->pageSize = 50;
		$pages->applyLimit($criteria);

		$sort = new CSort('User');
		$sort->defaultOrder = 'id ASC';
		$sort->applyOrder($criteria);


		$users = User::model()->findAll($criteria);

		$this->render('users', array(
				'users' => $users,
				'pages' => $pages,
				'sort' => $sort,
		));

	}

	public function actionRoles() {
		$roles = Role::model()->findAll();
		$this->render('roles', array('roles' => $roles));
	}
}
?>
